# This file is part of BlackArch Linux ( https://www.blackarch.org/ ).
# See COPYING for license details.

pkgname=sn1per
_pkgname=sniper
pkgver=624.feeb5c6
pkgrel=1
epoch=1
pkgdesc='Automated Pentest Recon Scanner.'
groups=('blackarch' 'blackarch-automation' 'blackarch-cracker'
        'blackarch-recon' 'blackarch-scanner')
url='https://github.com/1N3/Sn1per'
license=('custom:unknown')
arch=('any')
depends=('amap' 'arachni' 'bash' 'bind' 'brutex' 'cisco-torch' 'curl' 'jq'
         'cutycapt' 'dnsenum' 'dos2unix' 'enum4linux' 'firefox' 'golismero'
         'goohak' 'hydra' 'metasploit' 'nbtscan' 'nikto' 'nmap' 'php' 'nodejs'
         'postgresql' 'python' 'python-colorama' 'python-dnspython' 'rpcbind'
         'python-paramiko' 'python-requests' 'python-requests-file' 'dnsrecon'
         'python-tldextract' 'python-urllib3' 'ruby' 'ruby-mechanize'
         'ruby-net-http-persistent' 'ruby-rake' 'ruby-ruby-nmap' 'android-tools'
         'ruby-text-table' 'smtp-user-enum' 'sqlmap' 'sslscan' 'sslyze'
         'testssl.sh' 'theharvester' 'unzip' 'w3af' 'wapiti' 'whatweb'
         'whois' 'wpscan' 'xprobe2' 'xsstracer' 'xdg-utils')
makedepends=('git')
source=("$pkgname::git+https://github.com/1N3/Sn1per.git")
sha512sums=('SKIP')
install="$pkgname.install"

pkgver() {
  cd $pkgname

  echo $(git rev-list --count HEAD).$(git rev-parse --short HEAD)
}

prepare() {
  cd $pkgname

  sed -i '/apt-get/d' install.sh
  sed -i '/msfdb/d' install.sh
}

package() {
  cd $pkgname

  install -dm 755 "$pkgdir/usr/bin"
  install -dm 755 "$pkgdir/usr/share/$_pkgname"

  install -Dm 644 -t "$pkgdir/usr/share/doc/$pkgname/" README.md CHANGELOG.md

  rm *.md

  cp -a --no-preserve=ownership * "$pkgdir/usr/share/$_pkgname/"

  cat > "$pkgdir/usr/bin/$pkgname" << EOF
#!/bin/sh
cd /usr/share/$_pkgname
exec bash ./$_pkgname "\$@"
EOF

  chmod +x "$pkgdir/usr/bin/$pkgname"
}

